GBML manual / Camera

camera_offset

The followed camera is centered on the target plus x across and y down, in pixels: a positive x shows more of what lies to the right of the target, a positive y more of what lies below it. 0 and 0 (the default) is exactly the target.

Sega Genesis: not built yet

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

camera_offset(x, y)

Arguments

NameType
xreal
yreal

Returns

Nothing.

Description

Shifts where the followed target sits on the screen. The camera is centered on the target plus x pixels across and y pixels down. A positive x shows more of what lies to the right of the target, so the target sits left of the middle. A positive y shows more of what lies below it, so the target sits above the middle.

A game that looks down a long corridor wants the hero low on the screen, so the camera is centered a little above them: camera_offset(0, -24). A side-scroller that runs right wants a bit more room in front: camera_offset(30, 0).

0 and 0 (the default) is exactly the target. Offsets are whole pixels, the number is rounded down, and it stays until you change it.

Room Properties and World Properties have the same setting in their Camera section. It is applied when the room starts, before any of your code runs, so a call to this function always has the last word.

Example

camera_offset(0, -24);

The camera looks 24 pixels above the target, so the target is drawn 24 pixels below the middle of the screen.

On the GBA

Whole pixels. A project-wide setting; a call in code always overrides what the Camera section of Room Properties set.

See also: The cameracamera_followcamera_dead_zonecamera_look_ahead